# -*- coding: utf-8 -*-
"""
@Time ： 2024/5/8 16:01
@Auth ： 李天天
"""
import random
import time

import requests

from Common.basepage import BasePage
from PageObjects.Main_page import MainPage
from PageObjects.Player_page import PlayerPage


def start_invite():
    # BasePage("d_one").start_middleware_app()

    time.sleep(2)
    # MainPage("d_one").click_AV()
    # time.sleep(1)

    PlayerPage("d_one").click_share()
    time.sleep(1)
    PlayerPage("d_one").click_slave_invite()
    time.sleep(1)
    PlayerPage("d_one").click_ok()


def back_to_main():
    # PlayerPage("d_one").press_key("home")
    PlayerPage("d_one").click_back()


def close_invite():
    PlayerPage("d_one").click_close()


def press_invite():
    # PlayerPage("d_one").open_video_by_SCHEME(qipuId="1072194926294501")
    MainPage("d_one").start_IQIYI_app()
    time.sleep(2)
    MainPage("d_one").click_first_television()
    while True:
        start_invite()
        time.sleep(10)
        # BasePage(device="d_two").save_img_for_player("平板起播截图")
        close_invite()
        time.sleep(2)


if __name__ == '__main__':
    while True:
        try:
            press_invite()
        except:
            try:
                # requests.get(url="https://api.day.app/s3KoLFVvWVWdYiiro2gKW/CX1E自动操作脚本可能出现问题")
                BasePage("d_one").press_key("back")
                time.sleep(1)
                BasePage("d_two").press_key("back")
            except:
                pass
            # BasePage("d_one").click_point(0.08, 0.509, "点击空白处返回")
            # back_to_main()
            # requests.get(url="https://api.day.app/s3KoLFVvWVWdYiiro2gKW/多屏1.0自动操作脚本可能出现问题")
